import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { CommonResponse, SingupParams } from '../../../../model';
import { environment } from './../../../../../environments/environment';
import { ApiService } from './../../../../core/api/api.service';
import { urlService } from './../../../../core/api/url';

@Injectable( )
export class RegisterService {

  constructor(
    private api: ApiService
  ) { }

  sendCodeForSignUp(data: { email: string } | { mobile: string }): Observable<CommonResponse<string>> {
    return this.api.post(urlService(environment.type, '注册用户时发送验证码'), data);
  }

  singup(params: SingupParams): Observable<CommonResponse<string>> {
    return this.api.post(urlService(environment.type, '注册用户'), params);
  }

  error(error: any) {
    this.api.goToWhere(error);
  }

}
